﻿#pragma once

#include "../Utils/HCNMath.h"

#include "CComplexInventoryTransaction.h"
#include "CEntity.h"
#include "TextHolder.h"

class C_Packet {
public:
	uintptr_t** vTable{};  // 0x0000
public:
	int getId();
	TextHolder* getName();
	template <class T>
	bool isInstanceOf() {
		T packet{};
		if (packet.vTable == this->vTable)
			return true;
		else
			return false;
	}
};

class LevelSoundEventPacket : public C_Packet {
private:
	[[maybe_unused]] uint8_t pad_[0x28]{};  // 0x8
public:
	int sound{};         // 0x28
	vec3_t pos{};        // 0x2C
	int extraData = -1;  // 0x38
private:
	[[maybe_unused]] int unknown = 0;  // 0x3C
public:
	TextHolder entityType{};             // 0x40
	bool isBabyMod = false;              // 0x60
	bool disableRelativeVolume = false;  // 0x61
	LevelSoundEventPacket();
};

class PlayerAuthInputPacket : public C_Packet {
public:
	uint64_t VTable{};  // 0x0000
	uint64_t num4294967298{};
	uint8_t padThingy[32]{};
	// uint64_t entityRuntimeId; //0x0020
	float pitch{};  // 0x0028
	float yaw{};
	vec3_t pos{};       // 0x0030
	float yawUnused{};  // 0x0038
	vec3_t velocity{};
	float InputAD{};  // 1 for A, -1 for D, multiply by sqrt(2)/2 if mixed with InputWS
	float InputWS{};  // 1 for W, -1 for S, multiply by sqrt(2)/2 if mixed with InputAD
	uint8_t epicpad[12]{};
	uint32_t inputKeys{};
	int zero{};
	int one{};
	int two{};
	int counter{};

public:
	PlayerAuthInputPacket();
	PlayerAuthInputPacket(vec3_t pos, float pitch, float yaw, float yawUnused);
};

/*class C_ActorFallPacket : public C_Packet {
private:
	char pad_0x8[0x28];  //0x8
public:
	C_ActorFallPacket();
	__int64 runtimeId;  // 0x28
	float fallDistance;
	bool isInVoid;
};*/

class C_PlayerActionPacket : public C_Packet {
public:
	C_PlayerActionPacket();
private:
	[[maybe_unused]] uint8_t pad_0x8[0x28]{};  // 0x8
public:
	vec3_ti blockPosition{};    // 0x28
	int face{};                 // 0x34
	int action{};               // 0x38
	__int64 entityRuntimeId{};  // 0x40
};

class C_SubChunkRequestPacket : public C_Packet {
public:
	C_SubChunkRequestPacket();
};

class C_EmotePacket : public C_Packet {
public:
	C_EmotePacket();
};

class C_AnimatePacket : public C_Packet {
public:
	C_AnimatePacket();

private:
	[[maybe_unused]] uint8_t padding[0x28]{};

public:
	int64_t entityId{};
	int64_t action{};
	float unknown{};
};

class C_NPCRequestPacket : public C_Packet {
public:
	C_NPCRequestPacket();
	long entityRuntimeId{};    // Test
private:
	[[maybe_unused]] __int64 Unknown0{};  // Test
	std::u8string Unknown1{};  // Test
	[[maybe_unused]] __int64 Unknown2{};  // Test
};

class PlayerSkinPacket : public C_Packet {
public:
	PlayerSkinPacket();

private:
	[[maybe_unused]] uint8_t padding[0x28]{};

public:
	__int64 UUID{};
	__int64 skin{};  // meant to be skin class
	std::u8string skinName{};
	std::u8string oldSkinName{};
};

class NetworkLatencyPacket : public C_Packet {
public:
	NetworkLatencyPacket();
	__int64 timeStamp{};   // Test
	bool sendBack{};       // Test
private:
	[[maybe_unused]] uint8_t pad[0x100]{};  // 0x0
};

class CommandRequestPacket : public C_Packet {
private:
	[[maybe_unused]] uint8_t pad_0x8[0x28]{};  // 0x8

public:
	TextHolder command{};
	uint8_t type{};

private:
	[[maybe_unused]] uint64_t unk[2]{};
	TextHolder text{};
	__int64 id{};
	[[maybe_unused]] uint16_t pad{};

public:
	CommandRequestPacket();
	CommandRequestPacket(std::u8string_view cmd, uint8_t t);
};

class C_InteractPacket : public C_Packet {
public:
	C_InteractPacket(/**enum InteractPacket::Action, class ActorRuntimeID, vec3_t const&*/);

private:
	[[maybe_unused]] uint8_t padding[0x28]{};

public:
	int action{};
	long target{};
};

class ActorEventPacket : public C_Packet {
public:
	uint64_t VTable{};           // 0x0000
	int two{};                   // 0x0008
	int one{};                   // 0x000C
private:
	[[maybe_unused]] uint8_t pad_0xC[0x20]{};  // 0x0010
public:
	uint64_t entityRuntimeId{};  // 0x0030
	char eventId{};              // 0x0038
private:
	[[maybe_unused]] uint8_t pad_0x39[0x5]{};  // 0x0039
public:
	int16_t itemId{};            // 0x003E
	// ActorEventPacket();
	ActorEventPacket(uint64_t entityRuntimeId, char eventId, int16_t itemId);
};

class C_MobEquipmentPacket : public C_Packet {
public:
	C_MobEquipmentPacket();
	C_MobEquipmentPacket(__int64 entityRuntimeId, C_ItemStack& item, int hotbarSlot, int inventorySlot);

private:
	[[maybe_unused]] uint8_t pad_0x8[0x28]{};  // 0x0
public:
	__int64 entityRuntimeId{};  // 0x28
	C_ItemStack item{};         // 0x30
	int inventorySlot{};        // 0xB8 DONT USE FOR PACKET SENDING
	int hotbarSlot{};           // 0xBC DONT USE FOR PACKET SENDING
	uint8_t windowId{};         // 0xC0  DONT USE FOR PACKET SENDING
	uint8_t windowId1{};        // 0xC1  DONT USE FOR PACKET SENDING
	uint8_t inventorySlot1{};   // 0xC2
	uint8_t hotbarSlot1{};      // 0xC3
	uint8_t windowId2{};        // 0xC4 ALL OF THIS IS PROBABLY BROKEN, DONT USE
private:
	[[maybe_unused]] uint8_t unknown1{};
};

class C_InventoryTransactionPacket : public C_Packet {
public:
	C_InventoryTransactionPacket();
	C_InventoryTransactionPacket(C_ComplexInventoryTransaction* transac) : C_InventoryTransactionPacket() {
		this->complexTransaction = transac;
	}

private:
	[[maybe_unused]] uint8_t pad_0x8[0x28]{};  // 0x8
public:
	int unknown = 0;                                      // 0x28
	__int64* unknownStart = 0;                            // 0x30
	__int64* unknownEnd = 0;                              // 0x38
	__int64 filler = 0;                                   // 0x40
	C_ComplexInventoryTransaction* complexTransaction{};  // 0x48
	uint8_t numTransactions{};                            // 0x50
};

class C_TextPacket : public C_Packet {
public:
	C_TextPacket();

	C_TextPacket(std::u8string_view name, std::u8string_view xboxid);
private:
	[[maybe_unused]] uint8_t gap0[0x28]{};
public:
	uint8_t messageType{};  // 0x28

	uint8_t gap[7]{};

	TextHolder sourceName{};         // 0x30
	TextHolder message{};            // 0x50
	uint8_t field_24222[24]{};       // 0x70
	bool translationNeeded = false;  // 0x88

	uint8_t ga2p[7]{};  // 0x89
	TextHolder xboxUserId{};
	TextHolder platformChatId{};
};

class C_TextPacket_view : public C_Packet {
public:
	C_TextPacket_view(std::u8string_view name, std::u8string_view xboxid);

private:
	[[maybe_unused]] uint8_t gap0[0x28]{};
public:
	uint8_t messageType{};  // 0x28
private:
	[[maybe_unused]] uint8_t gap[7]{};
public:
	TextHolder_view sourceName{};    // 0x30
	TextHolder_view message{};       // 0x50
private:
	[[maybe_unused]] uint8_t field_24222[24]{};  // 0x70
public:
	bool translationNeeded = false;  // 0x88
private:
	[[maybe_unused]] uint8_t ga2p[7]{};  // 0x89
public:
	TextHolder_view xboxUserId{};
	TextHolder_view platformChatId{};
};

class LoginPacket : public C_Packet {};
class PlayStatusPacket : public C_Packet {};
class PositionTrackingDBServerBroadcastPacket : public C_Packet {};
class PositionTrackingDBClientRequestPacket : public C_Packet {};
class ServerToClientHandshakePacket : public C_Packet {};
class ClientToServerHandshakePacket : public C_Packet {};
class ClientCacheStatusPacket : public C_Packet {};
class ClientCacheBlobStatusPacket : public C_Packet {};
class ClientCacheMissResponsePacket : public C_Packet {};
class ResourcePacksInfoPacket : public C_Packet {};
class ResourcePackStackPacket : public C_Packet {};
class ResourcePackClientResponsePacket : public C_Packet {};
class DisconnectPacket : public C_Packet {};
class SetTimePacket : public C_Packet {};
class StartGamePacket : public C_Packet {};
class AddActorPacket : public C_Packet {};
class AddEntityPacket : public C_Packet {};
class AddItemActorPacket : public C_Packet {};
class TakeItemActorPacket : public C_Packet {};
class AddPlayerPacket : public C_Packet {};
class MoveActorAbsolutePacket : public C_Packet {};
class MoveActorDeltaPacket : public C_Packet {};
class MovePlayerPacket : public C_Packet {};
class RiderJumpPacket : public C_Packet {};
class RespawnPacket : public C_Packet {};
class RemoveActorPacket : public C_Packet {};
class RemoveEntityPacket : public C_Packet {};
class UpdateBlockPacket : public C_Packet {};
class UpdateBlockSyncedPacket : public C_Packet {};
class SpawnParticleEffectPacket : public C_Packet {};
class LevelSoundEventPacketV2 : public C_Packet {};
class LevelSoundEventPacketV1 : public C_Packet {};
class LevelEventPacket : public C_Packet {};
class LevelEventGenericPacket : public C_Packet {};

class BlockEventPacket : public C_Packet {
	/*0*/ virtual ~BlockEventPacket();
	/*1*/ virtual enum MinecraftPacketIds getId() const;
	/*2*/ virtual std::u8string getName() const;
	/*3*/ virtual void write(class BinaryStream&) const;
	/*6*/ virtual enum StreamReadResult _read(class ReadOnlyBinaryStream&);
};

class BlockPickRequestPacket : public C_Packet {};
class ActorPickRequestPacket : public C_Packet {};
class GuiDataPickItemPacket : public C_Packet {};
class MobEffectPacket : public C_Packet {};
class MobArmorEquipmentPacket : public C_Packet {};
class HurtArmorPacket : public C_Packet {};
class PlayerArmorDamagePacket : public C_Packet {};
class SetActorDataPacket : public C_Packet {};
class SetActorMotionPacket : public C_Packet {};
class MotionPredictionHintsPacket : public C_Packet {};
class SetHealthPacket : public C_Packet {};
class SetSpawnPositionPacket : public C_Packet {};
class ItemFrameDropItemPacket : public C_Packet {};
class ContainerOpenPacket : public C_Packet {};
class ContainerClosePacket : public C_Packet {};
class ContainerSetDataPacket : public C_Packet {};
class PlayerHotbarPacket : public C_Packet {};
class InventoryContentPacket : public C_Packet {};
class InventorySlotPacket : public C_Packet {};
class CraftingDataPacket : public C_Packet {};
class CraftingEventPacket : public C_Packet {};
class AddPaintingPacket : public C_Packet {};
class AdventureSettingsPacket : public C_Packet {};
class SetActorLinkPacket : public C_Packet {};
class BlockActorDataPacket : public C_Packet {};
class PlayerInputPacket : public C_Packet {};
class LevelChunkPacket : public C_Packet {};
class SetCommandsEnabledPacket : public C_Packet {};
class SetDifficultyPacket : public C_Packet {};
class ChangeDimensionPacket : public C_Packet {};
class SetPlayerGameTypePacket : public C_Packet {};
class UpdatePlayerGameTypePacket : public C_Packet {};
class SetDefaultGameTypePacket : public C_Packet {};
class UpdateAttributesPacket : public C_Packet {};
class PlayerListPacket : public C_Packet {};
class SimpleEventPacket : public C_Packet {};
class EventPacket : public C_Packet {};
class SpawnExperienceOrbPacket : public C_Packet {};
class RequestChunkRadiusPacket : public C_Packet {};
class ChunkRadiusUpdatedPacket : public C_Packet {};
class ClientboundMapItemDataPacket : public C_Packet {};
class MapCreateLockedCopyPacket : public C_Packet {};
class MapInfoRequestPacket : public C_Packet {};
class UpdateTradePacket : public C_Packet {};
class UpdateEquipPacket : public C_Packet {};
class BossEventPacket : public C_Packet {};
class AvailableCommandsPacket : public C_Packet {};
class CommandOutputPacket : public C_Packet {};
class CommandBlockUpdatePacket : public C_Packet {};
class CameraPacket : public C_Packet {};
class CameraShakePacket : public C_Packet {};
class GameRulesChangedPacket : public C_Packet {};
class ShowCreditsPacket : public C_Packet {};
class ResourcePackDataInfoPacket : public C_Packet {};
class ResourcePackChunkDataPacket : public C_Packet {};
class ResourcePackChunkRequestPacket : public C_Packet {};
class NetworkChunkPublisherUpdatePacket : public C_Packet {};
class StructureBlockUpdatePacket : public C_Packet {};
class StructureTemplateDataRequestPacket : public C_Packet {};
class StructureTemplateDataResponsePacket : public C_Packet {};
class TransferPacket : public C_Packet {};
class AddBehaviorTreePacket : public C_Packet {};
class SetTitlePacket : public C_Packet {};
class PlaySoundPacket : public C_Packet {};
class StopSoundPacket : public C_Packet {};
class ShowStoreOfferPacket : public C_Packet {};
class RemoveObjectivePacket : public C_Packet {};
class SetDisplayObjectivePacket : public C_Packet {};
class PurchaseReceiptPacket : public C_Packet {};
class SetScorePacket : public C_Packet {};
class SetScoreboardIdentityPacket : public C_Packet {};
class SubClientLoginPacket : public C_Packet {};
class SetLastHurtByPacket : public C_Packet {};
class BookEditPacket : public C_Packet {};
class AutomationClientConnectPacket : public C_Packet {};
class ModalFormRequestPacket : public C_Packet {};
class ModalFormResponsePacket : public C_Packet {};
class OnScreenTextureAnimationPacket : public C_Packet {};
class ServerSettingsRequestPacket : public C_Packet {};
class ServerSettingsResponsePacket : public C_Packet {};
class PhotoTransferPacket : public C_Packet {};
class ShowProfilePacket : public C_Packet {};
class LabTablePacket : public C_Packet {};
class UpdateSoftEnumPacket : public C_Packet {};
class SetLocalPlayerAsInitializedPacket : public C_Packet {};
class ScriptCustomEventPacket : public C_Packet {};
class BiomeDefinitionListPacket : public C_Packet {};
class AvailableActorIdentifiersPacket : public C_Packet {};
class LecternUpdatePacket : public C_Packet {};
class EducationSettingsPacket : public C_Packet {};
class SettingsCommandPacket : public C_Packet {};
class EmoteListPacket : public C_Packet {};
class MultiplayerSettingsPacket : public C_Packet {};
class AnvilDamagePacket : public C_Packet {};
class TickSyncPacket : public C_Packet {};
class CompletedUsingItemPacket : public C_Packet {};
class CreativeContentPacket : public C_Packet {};
class NetworkSettingsPacket : public C_Packet {};
class PlayerEnchantOptionsPacket : public C_Packet {};
class ItemStackRequestPacket : public C_Packet {};
class ItemStackResponsePacket : public C_Packet {};
class CodeBuilderPacket : public C_Packet {};
class DebugInfoPacket : public C_Packet {};
class PacketViolationWarningPacket : public C_Packet {};
class AnimateEntityPacket : public C_Packet {};
class PlayerFogPacket : public C_Packet {};
class CorrectPlayerMovePredictionPacket : public C_Packet {};
class ItemComponentPacket : public C_Packet {};
class FilterTextPacket : public C_Packet {};
class SyncActorPropertyPacket : public C_Packet {};
class ClientboundDebugRendererPacket : public C_Packet {};
class AddVolumeEntityPacket : public C_Packet {};
class RemoveVolumeEntityPacket : public C_Packet {};
class NpcDialoguePacket : public C_Packet {};
class SimulationTypePacket : public C_Packet {};
class CreatePhotoPacket : public C_Packet {};
class EduUriResourcePacket : public C_Packet {};
// class UpdateSubChunkBlocksPacket : public C_Packet {};

#pragma pack(push, 8)

__declspec(align(8)) class C_MovePlayerPacket : public C_Packet {
public:
	C_MovePlayerPacket();
	C_MovePlayerPacket(C_LocalPlayer* player, vec3_t pos);

	// uintptr_t** vTable;		// 0x0
private:
	char filler[0x28]{};  // 0x8
public:
	__int64 entityRuntimeID{};  // 0x28
	vec3_t Position{};          // 0x30
	float pitch{};              // 0x3c
	float yaw{};                // 0x40
	float headYaw{};            // 0x44
	uint8_t mode{};             // 0x48
	bool onGround{};
	__int64 ridingEid{};
	int int1{};
	int int2{};
};

#pragma pack(pop)
